import { createApp, Directive,getCurrentInstance } from 'vue'
import App from './App.vue'
import '@/permission.ts';
import router from './router/index'
import Pinia from './store/createPiniaStore';
import { registerStore } from './store/index';
import Antd from 'ant-design-vue';
import 'ant-design-vue/dist/antd.css';
import './style.css'
// import * as directives from '@/directives';
import loadingDirective from '@/directives/loading';
import BaseLoading from '@/components/base-loading/index.vue';
import BaseIcon from '@/components/base-icon/index.vue';
import BaseDialog from '@/components/base-dialog/index.vue';
import BaseDrawer from '@/components/base-drawer/index.vue';
import appStore from "@/store";
import vue3TreeOrg from 'vue3-tree-org';
import "vue3-tree-org/lib/vue3-tree-org.css";

const app = createApp(App)
app.use(router)
app.use(Pinia)
app.use(vue3TreeOrg)
// 注册pinia状态管理库
registerStore();
app.use(Antd);
app.directive('loading', loadingDirective);
// 注册-loading加载全局组件
app.component('BaseLoading', BaseLoading);
// 注册-icon图标全局组件
app.component('BaseIcon', BaseIcon);
// 注册-dialog弹框全局组件
app.component('BaseDialog', BaseDialog);
// 注册-drawer抽屉全局组件
app.component('BaseDrawer', BaseDrawer);
// 注册-全局方法
app.config.globalProperties.$appStore = appStore;
app.mount('#app')

// 全局注册自定义指令
// Object.keys(directives).forEach((key) => {
//   app.directive(key, (directives as { [key: string]: Directive })[key]);
// });